package cn.tsoft.common
{
	import flash.display.DisplayObject;

	public class MonitorToken implements IMonitorToken
	{
		
		private static const DEFAULT_LABEL:String="请稍等,正在处理中......";
		
		private var _owner:IProgressMonitor;
		
		private var _target:Object ;
		private var _cancelHandler:Function;
		private var _label:String ;
		private var _minValue:Number = 0;
		private var _curVaule:Number = 0;
		private var _maxValue:Number = 0;
		private var _parent:DisplayObject ;
		
		public function MonitorToken(owner:IProgressMonitor,target:Object,parent:DisplayObject,cancelHandler:Function=null)
		{
			this._owner = owner;
			this._target = target;
			this._parent = parent;
			this._cancelHandler =cancelHandler;
		}

		public function get target():Object
		{
			return _target;
		}
		
		public function get parent():DisplayObject
		{
			return _parent;
		}
		
		public function get cancelHandler():Function
		{
			return _cancelHandler;
		}
		
		public function set label(value:String):void
		{
			this._label = value;
		}
		
		public function get label():String
		{
			return _label==null?DEFAULT_LABEL:_label;
		}
		
		public function get minValue():Number
		{
			return _minValue;
		}
		
		public function set minValue(value:Number):void
		{
			this._minValue = value;
		}
		
		public function get curValue():Number
		{
			return _curVaule;
		}
		
		public function set curValue(value:Number):void
		{
			this._curVaule = value;
		}
		
		public function get maxValue():Number
		{
			return _maxValue;
		}
		
		public function set maxValue(value:Number):void
		{
			this._maxValue = value;
		}
		
		
		public function update(curValue:Number,lable:String):void
		{
			_owner.update(this,curValue,label);
		}
		
		public function stop():void
		{
			_owner.stop(this);
		}
		
	}
}